package com.lxmes.device.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lxmes.common.annotation.Log;
import com.lxmes.common.core.controller.BaseController;
import com.lxmes.common.core.domain.AjaxResult;
import com.lxmes.common.enums.BusinessType;
import com.lxmes.device.domain.NcEmJggl;
import com.lxmes.device.service.INcEmJgglService;
import com.lxmes.common.utils.poi.ExcelUtil;
import com.lxmes.common.core.page.TableDataInfo;

/**
 * 加工程序管理Controller
 * 
 * @author ruoyi
 * @date 2023-02-11
 */
@RestController
@RequestMapping("/device/jggl")
public class NcEmJgglController extends BaseController
{
    @Autowired
    private INcEmJgglService ncEmJgglService;

    /**
     * 查询加工程序管理列表
     */
    @PreAuthorize("@ss.hasPermi('device:jggl:list')")
    @GetMapping("/list")
    public TableDataInfo list(NcEmJggl ncEmJggl)
    {
        startPage();
        List<NcEmJggl> list = ncEmJgglService.selectNcEmJgglList(ncEmJggl);
        return getDataTable(list);
    }

    /**
     * 导出加工程序管理列表
     */
    @PreAuthorize("@ss.hasPermi('device:jggl:export')")
    @Log(title = "加工程序管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, NcEmJggl ncEmJggl)
    {
        List<NcEmJggl> list = ncEmJgglService.selectNcEmJgglList(ncEmJggl);
        ExcelUtil<NcEmJggl> util = new ExcelUtil<NcEmJggl>(NcEmJggl.class);
        util.exportExcel(response, list, "加工程序管理数据");
    }

    /**
     * 获取加工程序管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('device:jggl:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(ncEmJgglService.selectNcEmJgglById(id));
    }

    /**
     * 新增加工程序管理
     */
    @PreAuthorize("@ss.hasPermi('device:jggl:add')")
    @Log(title = "加工程序管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody NcEmJggl ncEmJggl)
    {
        return toAjax(ncEmJgglService.insertNcEmJggl(ncEmJggl));
    }

    /**
     * 修改加工程序管理
     */
    @PreAuthorize("@ss.hasPermi('device:jggl:edit')")
    @Log(title = "加工程序管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody NcEmJggl ncEmJggl)
    {
        return toAjax(ncEmJgglService.updateNcEmJggl(ncEmJggl));
    }

    /**
     * 删除加工程序管理
     */
    @PreAuthorize("@ss.hasPermi('device:jggl:remove')")
    @Log(title = "加工程序管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ncEmJgglService.deleteNcEmJgglByIds(ids));
    }
}
